import static org.junit.Assert.*;
import org.junit.Test;
import org.junit.Before;
import org.junit.After;

/**
* @author Irina
*This class implements is the test cases for VendingMachineItem class
*
*/
public class VendingMachineItemTest {

/**
* @throws java.lang.Exception
*/
//Declaring variable of type VendingMachineItem
VendingMachineItem vmi_item; 

//creating new instance of VendingMachineItem before running a test case
@Before 
public void setUp() throws Exception { 

vmi_item = new VendingMachineItem("Coke", 1.50); 
} 

//testing if the name is a valid name
@Test 
public void testVendingMachineItem_validName() { 
assertEquals("Coke", vmi_item.getName()); 
} 

//Testing if the VendingMachineItem() works when a price a valid price is passed
@Test 
public void testVendingMachineItem_validPrice() { 
assertEquals(1.5, vmi_item.getPrice(), 0); 
} 

//testing if the VendingMachineItem() works when a price zero is passed
@Test 
public void testVendingMachineItem_zeroPrice() { 
vmi_item = new VendingMachineItem("Coke", 0.0); 
assertEquals(0.0, vmi_item.getPrice(), 0); 
} 

//Testing if the VendingMachineItem() works when a price less than zero is passed
@Test(expected = VendingMachineException.class) 
public void testVendingMachineItem_invalidPrice() {
vmi_item = new VendingMachineItem("Coke", -1.0); 
assertEquals(-1.0, vmi_item.getPrice(), 0); 
}

//Testing if the GetName() is returning the valid item name
@Test 
public void testGetName() { 
assertEquals("Coke", vmi_item.getName()); 
}

//Testing if the GetPrice() is returning the valid item price
@Test 
public void testGetPrice() { 
assertEquals(1.50, vmi_item.getPrice(), 0); 
} 

//Clearing any previous value of vmi_item after a test case completed running
@After 
public void TearDown() throws Exception { 
vmi_item = null; 
} 


}

